use std::ops::Index;

struct Solution {}

fn main() {}

impl Solution {
    pub fn dominant_index(nums: Vec<i32>) -> i32 {
        let mut nums_cp = nums.clone();
        nums_cp.sort();
        nums_cp.reverse();

        if nums_cp[0] >= nums_cp[1] * 2 {
            let i = nums_cp[0];
            let result = nums.iter().position(|&e| e == i);
            return result.unwrap() as i32;
        }
        -1
    }
}